import java.util.Scanner;

/**
 * 凯撒日期
 */
public class Kaiseriqi {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入年份");
        int year = sc.nextInt();
        System.out.println("请输入月份");
        int month = sc.nextInt();
        System.out.println("请输入日期");
        int day = sc.nextInt();
        int feb,maxDay = 0;
        boolean runnian = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;

        switch (month){
            case 1: case 3: case 5: case 7: case 8: case 10: case 12:
                maxDay = 31;break;
            case 4: case 6: case 9: case 11:
                maxDay = 30;break;
            case 2:if (runnian) {
                maxDay = 29;break;
            }else {
                maxDay = 28;break;
            }
            default:
                System.out.println("输入非法");
                System.exit(2);
        }
        if (day < 1 || day > maxDay) {
            System.out.println("输入非法");
            System.exit(2);
        }
        int days = 0;
        switch (month - 1) {
            case 11:
                days += 30;
            case 10:
                days += 31;
            case 9:
                days += 30;
            case 8:
                days += 31;
            case 7:
                days += 31;
            case 6:
                days += 30;
            case 5:
                days += 31;
            case 4:
                days += 30;
            case 3:
                days += 31;
            case 2:
                if (runnian) {
                    days += 29;
                } else {
                    days += 28;
                }
            case 1:
                days += 31;
            case 0:
                break;
            default:
                System.out.println("月份非法");
        }
        System.out.printf("在这一年的第%d天", days + day);
    }
}
//        if (runnian) {
//            feb = 29;
//        } else {
//            feb = 28;
//        }
//          int maxday;
//        if (month == 2) {
//            if (day < 1 || day > maxday) {
//                System.out.println("输入非法");
//                System.exit(20);
//            }//判断月份是否合法
//        } else if (month == 4 || month == 6 || month == 9 || month == 11) {
//            if (day < 1 || day > 30) {
//                System.out.println("输入非法");
//                System.exit(20);
//            }
//        } else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
//            if (day < 1 || day > 31) {
//                System.out.println("输入非法");
//                System.exit(20);
//            }
//        }